package com.music.controller;

import com.music.pojo.Feedback;
import com.music.service.FeedbackService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.*;

@Controller
public class FeedbackController {
    @Autowired
    private FeedbackService feedbackService;

    @RequestMapping("/findAllFeedback")
    @ResponseBody
    public List<Feedback> findAllFeedback(){
        List<Feedback> list=feedbackService.findAllFeedback();
        return list;
    }

    @RequestMapping("/findInfoTAndH_Feedback")
    @ResponseBody
    public List<Feedback> findInfoTAndH_Feedback(){
        Feedback feedback=new Feedback();
        feedback.setType("歌曲问题");
        feedback.setHandle("待处理");
        List<Feedback> list=feedbackService.findInfoTAndH_Feedback(feedback);
        return list;
    }

    @RequestMapping("/addFeedback")
    @ResponseBody
    public Map<Object,Object> addFeedback(){
        Feedback feedback=new Feedback();
        feedback.setUser_id(1);
        feedback.setDetail("1w81d1ee");
        feedback.setType("歌词问题");
        feedback.setHandle("已处理");
        Map<Object,Object> result=new HashMap();
        boolean flag=feedbackService.addFeedback(feedback);
        if(flag) {
            result.put("status", "200");
            result.put("msg", "success");
        }
        return result;
    }

    @RequestMapping("/deleteFeedback")
    @ResponseBody
    public Map<Object,Object> deleteeedback(){
        int[] ids={1,2};
        Map<Object,Object> result=new HashMap();
        boolean flag=feedbackService.deleteFeedback(ids);
        if(flag) {
            result.put("status", "200");
            result.put("msg", "success");
        }
        return result;
    }

    @RequestMapping("/updateFeedback")
    @ResponseBody
    public Map<Object,Object> updateFeedback(){
        Feedback feedback=new Feedback();
        feedback.setId(3);
        feedback.setHandle("已处理");
        Map<Object,Object> result=new HashMap();
        boolean flag=feedbackService.updateFeedback(feedback);
        if(flag) {
            result.put("status", "200");
            result.put("msg", "success");
        }
        return result;
    }
}
